<?php

namespace app\user\controller;
use app\logic\WeChatPay as LogicWeChatPay;
use app\model\UserOrder as ModelUserOrder;

class Center extends Member
{
    public function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 获取活动消息列表
     * URI: /user/get.message.list
     */
    public function getMessageList()
    {
        $obj = new \app\logic\push\ClientPush($this->str_module_name);
        $int_now_page = intval($this->_getContentParams('page'));
        $int_list_rows = intval($this->_getContentParams('listRows'));
        $obj->getActivityMessageList($this->user_id, $int_now_page, $int_list_rows);
    }

    /**
     * 获取活动消息详情
     * URI: /user/get.message.info
     */
    public function getMessageInfo()
    {
        $str_module_name = $this->_getContentParams($this->str_module_name);
        $obj = new \app\logic\push\ClientPush($str_module_name);
        $int_message_id = $this->_getContentParams('messageId');
        $obj->getMessageInfo('activity', $int_message_id);
    }
    /*
     * 微信支付
     * URI:/user/wechat.pay
     */
    public function weChatPaySubmit()
    {
//        $orderId = $this->_getContentParams('orderId');
//        _toValidate('id',$orderId,10009);
        $bool_res = LogicWeChatPay::getInstance()->weChatAppPay('111',0.01);
        echo $bool_res;

    }
    /*
     * 用户订单付款
     * type:1:微信押金，2：支付宝押金
     * URI:/user/payment.submit
     */
    public function submitPay()
    {
        $orderId = $this->_getContentParams('orderId');
        _toValidate('id',$orderId,10009);
        $type = $this->_getContentParams('type');
        $module = $this->_getContentParams('module');
        _toCompare($module,'!=','user',10823);

        //入驻单号
        $orderInfo = ModelUserOrder::getInstance()->toFind(['order_id'=>$orderId]);
        switch ($type) {
            case 1 : //微信押金付款
//                $res = LogicWeChatPay::getInstance()->weChatAppPay('YJ20180418111111',0.01);
                break;
            case 2 : //支付宝押金
                $payInfo = \app\logic\AliPay::getInstance()->aliAppPay($orderInfo['order_sn'], $orderInfo['order_amount'],$module);
                break;
            default :
                _returnError(10014);
                break;

        }
        _returnData(['payInfo'=>$payInfo]);
    }
}
